package com.aifast.system.sys.dao;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.aifast.system.sys.entity.SysMessage;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;

/**
 * 站内信Mapper接口
 *
 * @author fujian
 * @date 2022-10-19
 */
@Mapper
public interface SysMessageDao extends BaseMapper<SysMessage> {

    default LambdaQueryWrapper<SysMessage> select(Integer type, String message) {
        return new LambdaQueryWrapper<SysMessage>()
                .eq(ObjectUtil.isNotNull(type), SysMessage::getType, type)
                .like(StrUtil.isNotBlank(message), SysMessage::getMessage, message)
                .orderByDesc(SysMessage::getId);
    }

}
